﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

namespace Utility.BehaviourTree
{
	public static partial class BTNodes
	{
		#region root
		public static BTRootNode Root ()
		{
			return new BTRootNode ();
		}
		#endregion
		#region composite
		public static SelectorNode Select ()
		{
			return new SelectorNode ();
		}

		public static SequenceNode Sequence ()
		{
			return new SequenceNode ();
		}

		public static RandomSelectorNode RndSelect ()
		{
			return new RandomSelectorNode ();
		}
		#endregion
		#region decorator
		public static AlwaysSucceedNode Success ()
		{
			return new AlwaysSucceedNode ();
		}

		public static AlwaysFailNode Fail ()
		{
			return new AlwaysFailNode ();
		}

		public static DataNode Data (DataBoard databoard = null)
		{
			return new DataNode (databoard);
		}

		public static IfNode If (Func<DataBoard, bool> condition)
		{
			return new IfNode (condition);
		}

		public static InverterNode Invert ()
		{
			return new InverterNode ();
		}

		public static RepeaterNode Repeat (int count = -1)
		{
			return new RepeaterNode (count);
		}

		public static UntilFailNode UntilFail ()
		{
			return new UntilFailNode ();
		}

		public static UntilSuccessNode UntilSuccess ()
		{
			return new UntilSuccessNode ();
		}
		#endregion
		#region leaf
		public static ActNode Act (Action<DataBoard> action)
		{
			return new ActNode (action);
		}

		public static TaskNode Task (Func<DataBoard, Status> taskFunc)
		{
			return new TaskNode (taskFunc);
		}

		#region check
		//condition
		public static CheckNode Check (Func<DataBoard, bool> condition)
		{
			return new CheckConditionNode (condition);
		}

		//object
		public static CheckNode CheckNotNull (string key)
		{
			return new CheckNotNullNode (key);
		}

		public static CheckNode CheckNotNull<T> (string key)
			where T : class
		{
			return new CheckNotNullNode<T> (key);
		}

		//int
		public static CheckNode CheckEqual (string key, int value)
		{
			return new CheckIntNode (key, value, CheckType.Equal);
		}

		public static CheckNode CheckGreater (string key, int value)
		{
			return new CheckIntNode (key, value, CheckType.Greater);
		}

		public static CheckNode CheckGreaterEqual (string key, int value)
		{
			return new CheckIntNode (key, value, CheckType.GreaterEqual);
		}

		public static CheckNode CheckLess (string key, int value)
		{
			return new CheckIntNode (key, value, CheckType.Less);
		}

		public static CheckNode CheckLessEqual (string key, int value)
		{
			return new CheckIntNode (key, value, CheckType.LessEqual);
		}

		//float
		public static CheckNode CheckEqual (string key, float value)
		{
			return new CheckFloatNode (key, value, CheckType.Equal);
		}

		public static CheckNode CheckGreater (string key, float value)
		{
			return new CheckFloatNode (key, value, CheckType.Greater);
		}

		public static CheckNode CheckGreaterEqual (string key, float value)
		{
			return new CheckFloatNode (key, value, CheckType.GreaterEqual);
		}

		public static CheckNode CheckLess (string key, float value)
		{
			return new CheckFloatNode (key, value, CheckType.Less);
		}

		public static CheckNode CheckLessEqual (string key, float value)
		{
			return new CheckFloatNode (key, value, CheckType.LessEqual);
		}

		//bool
		public static CheckNode CheckBool (string key, bool value = true)
		{
			return new CheckBoolNode (key, value);
		}
		#endregion

		public static WaitNode Wait (float t)
		{
			return new WaitNode (t);
		}

		public static PrintNode Print (string str, Status status = Status.Success)
		{
			return new PrintNode (str, status);
		}
		#endregion
	}
}